﻿namespace EFS.RC.SupervisorCentral.Controls.Agents
{
	public class ContactListItem : System.Windows.Controls.UserControl
	{
		#region Delegates
		/// Button cliked
		public delegate void ButtonClickedDlg(
			System.Windows.RoutedEventArgs routedEventArgs,
			eButtonType buttonType,
			System.String agentSIP,
			System.String ACD);
		public ButtonClickedDlg OnButtonClickedDlg;
		#endregion

		/// Enum eButtonType
		public enum eButtonType
		{
			Listen,
			RemoveFromACD,
			AddToACD
		}

		public ContactListItem()
		{
			// set initial
			LastUpdate = System.DateTime.Now;

			// ignore in design tool
			if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
			{
				this.Loaded += new System.Windows.RoutedEventHandler(ContactListItem_Loaded);
				this.Initialized += new System.EventHandler(ContactListItem_Initialized);
			}
		}

		/// Update
		public virtual void Update()
		{
			LastUpdate = System.DateTime.Now;
		}

		#region Properties
		/// Property CustomContactListItem: Get
		protected virtual Microsoft.Lync.Controls.CustomContactListItem LyncCustomContactListItem
		{
			get
			{
				throw new System.NotImplementedException("LyncCustomContactListItem");
			}
		}

		/// Property ContactLayoutView: Get, Set
		public Microsoft.Lync.Controls.ContactLayoutOption ContactLayoutView
		{
			get
			{
				return LyncCustomContactListItem.ContactLayoutView;
			}
			set
			{
				LyncCustomContactListItem.ContactLayoutView = value;
			}
		}

		/// Property LastUpdate: Get, Set
		public System.DateTime LastUpdate { get; protected set; }

		/// Property ACD: Get, Set
		public System.String ACD { get; set; }

		/// Property RequiredSkillId: Get, Set
		public System.Int32 RequiredSkillId { get; set; }

		/// Property Source: Get, Set
		public System.String Source
		{
			get
			{
				return null != LyncCustomContactListItem.Source ? LyncCustomContactListItem.Source.ToString() : "";
			}
			set
			{
				LyncCustomContactListItem.Source = value;
			}
		}

		/// Property AgentStatus: Get, Set
		public EFS.RC.CC.Messages.Agents.Status AgentStatus
		{
			get
			{
				return EFS.RC.SupervisorCentral.Common.Session.Instance.AgentList[Source];
			}
		}
		#endregion

		#region ControlEvents
		/// ContactListItem_Initialized
		private void ContactListItem_Initialized(object sender, System.EventArgs e)
		{
			LyncCustomContactListItem.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(LyncCustomContactListItem_PreviewMouseLeftButtonDown);
			LyncCustomContactListItem.PreviewMouseMove += new System.Windows.Input.MouseEventHandler(LyncCustomContactListItem_PreviewMouseMove);
			LyncCustomContactListItem.Loaded += new System.Windows.RoutedEventHandler(LyncCustomContactListItem_Loaded);
		}

		/// Control Loaded
		private void ContactListItem_Loaded(object sender, System.Windows.RoutedEventArgs e)
		{
		}

		/// OnButtonClicked
		protected void OnButtonClicked(System.Windows.RoutedEventArgs args, eButtonType buttonType, System.String agentSIP, System.String acd)
		{
			if (null != this.OnButtonClickedDlg)
			{
				this.OnButtonClickedDlg(args, buttonType, agentSIP, acd);
			}
		}

		/// LyncCustomContactListItem PreviewMouseMove
		private void LyncCustomContactListItem_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
		{
		}

		/// LyncCustomContactListItem PreviewMouseLeftButtonDown
		private void LyncCustomContactListItem_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
		}

		/// LyncCustomContactListItem_Loaded
		private void LyncCustomContactListItem_Loaded(object sender, System.Windows.RoutedEventArgs e)
		{
		}
		#endregion
	}

}